<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图书报损</title>
</head>
<body>
<div>
  <h1>
    图书报损
  </h1>



<!--    null,4,7,'5555','遗失','1')-->
    <div>
        <table id="table-list" class="table">

            <thead>
            <tr>
                <th>书籍名称</th>
                <th>价值</th>
                <th>书籍编号</th>
                <th>借阅者</th>
                <th>破损程度</th>
                <th>借阅者留言</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody class="list" id="tbody-list">
            </tbody>

        </table>

    </div>

</div>
</body>
</html>
<script src="/js/jquery-3.5.1.js"></script>
<script>

    $(document).ready(function() {
        $.post("/bookLoss.admin",function (text){
            let borObj=JSON.parse(text);
            console.log(borObj)

            for (let i = 0; i < borObj.length; i++) {
                    let str = "";
                    str += "<td>" + i + "</td>";
                    str += "<td>" + borObj[i].borName + "</td>";
                    str += "<td>" + borObj[i].bookName + "</td>";
                    str += "<td>" + borObj[i].price + "</td>";
                    str += "<td>" + borObj[i].bookNumber + "</td>";
                    str += "<td>" + borObj[i].damagedegree + "</td>";
                    str += "<td>" + borObj[i].bookDamageMsg + "</td>";
                    str += "<td>" + borObj[i].sendTime + "</td>";
                    let de=borObj[i].damagedegree;


                    str += "<td>" +
                        "<input type='button' class='bth' id='chu' value='处理' onclick= "+
                        "chuli(" + borObj[i].id + ",'"
                        +de
                        +"'"+")>";
                     str += "<td>" +
                        "<h3 id='ret'></h3>";
                    let tr = $("<tr>" + str + "</tr>");
                    $("#tbody-list").append(tr);
            }
        })
    })


function chuli(id,degree){
        $.post("/chulibook.admin",{"id":id,"degree":degree},function(text){
            $("#ret").val(text)
            $("#chu").attr("disabled",true)

            // if(text){
            //     $("#ret").val("处理成功")
            // }else{
            //     $("#ret").val("处理失败")
            // }
        })
}

</script>